![]() |
PATH![]() |
![]() ![]() |
The following Dialog Manager function for handling events in dialog boxes is changed with Appearance Manager 1.0:
Handles events while your application displays a modal or movable modal dialog box.
pascal void ModalDialog (
ModalFilterUPP modalFilter,
short *itemHit);
Call the ModalDialog function immediately after displaying a modal or movable modal dialog box. Your application should continue calling ModalDialog until the user dismisses your dialog.
For modal dialogs, the ModalDialog function repeatedly handles events until an event involving an enabled dialog box item--such as a click in a radio button, for example--occurs. If the event is a mouse-down event outside the content region of the dialog box, ModalDialog plays the system alert sound and gets the next event.
For movable modal dialogs, if the kDialogFlagsHandleMovableModal feature bit in the extended dialog resource is set, the ModalDialog function will handle all standard movable modal user interactions, such as dragging a dialog box by its title bar and allowing the user to switch into another application. However, a difference between the ModalDialog function's behavior with movable modal and modal dialogs is that, with movable modal dialogs, your event filter function receives all events. If you want the Dialog Manager to assist you in handling events in movable modal dialog boxes, call GetStdFilterProc and StdFilterProc .
For events inside the dialog box, ModalDialog passes the event to the event filter function pointed to in the modalFilter parameter before handling the event. When the event filter returns false , ModalDialog handles the event. If the event filter function handles the event, returning true , ModalDialog performs no more event handling.
If you set the modalFilter parameter to nil , the standard event filter function is executed. The standard event filter function checks whether
If you set the modalFilter parameter to point to your own event filter function, that function can use the standard filter function to accomplish the above tasks. (To do so, you can call GetStdFilterProc , and dispatch the event to the standard filter function yourself, or you can call StdFilterProc , which obtains a ModalFilterUPP for the standard filter function and then dispatches the function.) Additionally, your own event filter function should also
You can also use your event filter function to test for and respond to keyboard equivalents and more complex events--for instance, the user dragging the cursor within an application-defined item. You can use your same event filter function in most or all of your alert and modal dialog boxes.
If the event filter function does not handle the event (returning false ), ModalDialog handles the event as follows:
The ModalDialog function traps all events. This prevents your event loop from receiving activate events for your windows. Thus, if one of your application's windows is active when you use GetNewDialog to create a modal dialog box, you must explicitly deactivate that window before displaying the modal dialog box.
When ModalDialog calls the Control Manager function TrackControl , it does not allow you to specify the action function necessary for anything more complex than a button, radio button, or checkbox. If you need a more complex control, you can create your own control, a picture, or an application-defined item that draws a control-like object in your dialog box. You must then provide an event filter function that appropriately handles events in that item.
Previous | Back Up One Level | Next |